package git.soulbgm.initialize;

import git.soulbgm.common.socket.MonitorCenterServer;
import git.soulbgm.common.socket.MonitorDataHandler;
import git.soulbgm.config.SysConfig;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 启动监控数据侦听
 *
 * @author SoulBGM
 * @date 2024-04-11
 */
@Component
public class StartMonitorDataListening implements ApplicationRunner {

    private final MonitorDataHandler handler;
    private final int monitorPort;

    public StartMonitorDataListening(MonitorDataHandler handler, SysConfig config) {
        this.handler = handler;
        this.monitorPort = config.getMonitorPort();
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        MonitorCenterServer.initServer(handler, monitorPort);
    }
}
